namespace CodeConsult.Adafruit.BLE_UART
{
    public static class RfGoStudioServices
    {
        public const byte GapDeviceNameSetPipe = 0x01;
        public const byte UartOverBtleUartRxRxPipe = 0x02;
        public const byte UartOverBtleUartTxTxPipe = 0x03;
        public const byte DeviceInformationHardwareRevisionStringSetPipe = 0x04;

        /// <summary>
        /// Maximum connection interval as a multiple of 1.25 msec , 0xFFFF means no specific value requested.
        /// </summary>
        public const byte MaxConnIntGapPpcp = 0x12;

        /// <summary>
        /// Minimum connection interval as a multiple of 1.25 msec , 0xFFFF means no specific maximum.
        /// </summary>
        public const byte MinConnIntGapPpcp = 0x06;

        public const byte SlaveLatencyGapPpcp = 0x00;

        /// <summary>
        /// Connection Supervision timeout multiplier as a multiple of 10msec, 0xFFFF means no specific value requested.
        /// </summary>
        public const byte ConnTimeoutGapPpcp = 0x0a;

        /// <summary>
        /// Service pipe type specified in big endian.
        /// </summary>
        public static byte[][] ServicePipeTypeMappings { get; } =
            {
                new byte[] { 0x01, 0x00, 0x80 }, // Local, Set
                new byte[] { 0x01, 0x00, 0x08 }, // Local, Rx
                new byte[] { 0x01, 0x00, 0x02 }, // Local, Tx
                new byte[] { 0x01, 0x00, 0x80 }  // Local, Set
            };

        public static byte[][] SetupCommandMessages { get; } =
            {
                new byte[]
                {
                    0x07, 0x06, 0x00, 0x00, 0x03, 0x02, 0x41, 0xd7
                },
                new byte[]
                {
                    0x1f, 0x06, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x01, 0x01, 0x00, 0x00,
                    0x06, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
                },
                new byte[]
                {
                    0x1f, 0x06, 0x10, 0x1c, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x14, 0x03, 0x90, 0x01, 0x64
                },
                new byte[]
                {
                    0x1f, 0x06, 0x10, 0x38, 0x02, 0xff, 0x02, 0x58, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
                },
                new byte[]
                {
                    0x05, 0x06, 0x10, 0x54, 0x00, 0x00
                },
                new byte[]
                {
                    0x1f, 0x06, 0x20, 0x00, 0x04, 0x04, 0x02, 0x02, 0x00, 0x01, 0x28, 0x00, 0x01, 0x00, 0x18, 0x04, 0x04,
                    0x05, 0x05, 0x00, 0x02, 0x28, 0x03, 0x01, 0x0e, 0x03, 0x00, 0x00, 0x2a, 0x04, 0x14, 0x07
                },
                new byte[]
                {
                    0x1f, 0x06, 0x20, 0x1c, 0x04, 0x00, 0x03, 0x2a, 0x00, 0x01, 0x55, 0x41, 0x52, 0x54, 0x69, 0x63, 0x73,
                    0x04, 0x04, 0x05, 0x05, 0x00, 0x04, 0x28, 0x03, 0x01, 0x02, 0x05, 0x00, 0x01, 0x2a, 0x06
                },
                new byte[]
                {
                    0x1f, 0x06, 0x20, 0x38, 0x04, 0x03, 0x02, 0x00, 0x05, 0x2a, 0x01, 0x01, 0x00, 0x00, 0x04, 0x04, 0x05,
                    0x05, 0x00, 0x06, 0x28, 0x03, 0x01, 0x02, 0x07, 0x00, 0x04, 0x2a, 0x06, 0x04, 0x09, 0x08
                },
                new byte[]
                {
                    0x1f, 0x06, 0x20, 0x54, 0x00, 0x07, 0x2a, 0x04, 0x01, 0x06, 0x00, 0x12, 0x00, 0x00, 0x00, 0x0a, 0x00,
                    0x04, 0x04, 0x02, 0x02, 0x00, 0x08, 0x28, 0x00, 0x01, 0x01, 0x18, 0x04, 0x04, 0x10, 0x10
                },
                new byte[]
                {
                    0x1f, 0x06, 0x20, 0x70, 0x00, 0x09, 0x28, 0x00, 0x01, 0x9e, 0xca, 0xdc, 0x24, 0x0e, 0xe5, 0xa9, 0xe0,
                    0x93, 0xf3, 0xa3, 0xb5, 0x01, 0x00, 0x40, 0x6e, 0x04, 0x04, 0x13, 0x13, 0x00, 0x0a, 0x28
                },
                new byte[]
                {
                    0x1f, 0x06, 0x20, 0x8c, 0x03, 0x01, 0x04, 0x0b, 0x00, 0x9e, 0xca, 0xdc, 0x24, 0x0e, 0xe5, 0xa9, 0xe0,
                    0x93, 0xf3, 0xa3, 0xb5, 0x02, 0x00, 0x40, 0x6e, 0x44, 0x10, 0x14, 0x00, 0x00, 0x0b, 0x00
                },
                new byte[]
                {
                    0x1f, 0x06, 0x20, 0xa8, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x13, 0x13, 0x00, 0x0c
                },
                new byte[]
                {
                    0x1f, 0x06, 0x20, 0xc4, 0x28, 0x03, 0x01, 0x10, 0x0d, 0x00, 0x9e, 0xca, 0xdc, 0x24, 0x0e, 0xe5, 0xa9,
                    0xe0, 0x93, 0xf3, 0xa3, 0xb5, 0x03, 0x00, 0x40, 0x6e, 0x14, 0x00, 0x14, 0x00, 0x00, 0x0d
                },
                new byte[]
                {
                    0x1f, 0x06, 0x20, 0xe0, 0x00, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x14, 0x03, 0x02, 0x00
                },
                new byte[]
                {
                    0x1f, 0x06, 0x20, 0xfc, 0x0e, 0x29, 0x02, 0x01, 0x00, 0x00, 0x04, 0x04, 0x02, 0x02, 0x00, 0x0f, 0x28,
                    0x00, 0x01, 0x0a, 0x18, 0x04, 0x04, 0x05, 0x05, 0x00, 0x10, 0x28, 0x03, 0x01, 0x02, 0x11
                },
                new byte[]
                {
                    0x19, 0x06, 0x21, 0x18, 0x00, 0x27, 0x2a, 0x04, 0x04, 0x09, 0x01, 0x00, 0x11, 0x2a, 0x27, 0x01, 0x0a,
                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
                },
                new byte[]
                {
                    0x1f, 0x06, 0x40, 0x00, 0x2a, 0x00, 0x01, 0x00, 0x80, 0x04, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x02,
                    0x00, 0x08, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x03, 0x02, 0x00, 0x02, 0x04, 0x00, 0x0d
                },
                new byte[]
                {
                    0x0f, 0x06, 0x40, 0x1c, 0x00, 0x0e, 0x2a, 0x27, 0x01, 0x00, 0x80, 0x04, 0x00, 0x11, 0x00, 0x00
                },
                new byte[]
                {
                    0x13, 0x06, 0x50, 0x00, 0x9e, 0xca, 0xdc, 0x24, 0x0e, 0xe5, 0xa9, 0xe0, 0x93, 0xf3, 0xa3, 0xb5, 0x00,
                    0x00, 0x40, 0x6e
                },
                new byte[]
                {
                    0x0f, 0x06, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
                },
                new byte[]
                {
                    0x06, 0x06, 0xf0, 0x00, 0x03, 0xd3, 0x88
                }
            };
    }
}
